// 单轴
export function singleShaftBarLineOptions({ titleText, titleSubText, legendData, xAxisData, seriesBarName, seriesBarData, seriesLineName, serLineData }) {
  return {
    title: {
      text: titleText,
      subtext: titleSubText,
    },
    // 提示框组件
    tooltip: {},
    // 图例组件
    legend: {
      // 图例的数据数组
      data: legendData,
    },
    // 直角坐标系 grid 中的 x 轴
    xAxis: [
      {
        // 坐标轴类型。
        type: "category",
        // 类目数据，在类目轴（type: 'category'）中有效
        data: xAxisData,
      },
    ],
    yAxis: {
      type: "value",
    },
    series: [
      {
        name: seriesBarName,
        type: "bar",
        label: {
          show: true,
          position: "outside",
        },
        data: seriesBarData,
      },
      {
        name: seriesLineName,
        type: "line",
        label: {
          show: true,
          position: "outside",
        },
        data: serLineData,
      },
    ],
  }
}

// 双轴
export function doubleShaftBarLineOptions(obj) {
  return {
    title: {
      text: obj.titleText,
      subtext: obj.titleSubText,
    },
    // 提示框组件
    tooltip: {},
    // 图例组件
    legend: {
      // 图例的数据数组
      data: obj.legendData,
    },
    // 直角坐标系 grid 中的 x 轴
    xAxis: [
      {
        // 坐标轴类型。
        type: "category",
        // 类目数据，在类目轴（type: 'category'）中有效
        data: obj.xAxisData,
      },
    ],
    yAxis: [
      {
        type: 'value',
        min: 0,

        max: 400,
      },
      {
        type: 'value',
        min: 0,

        max: 80,
        nameLocation: obj.yAxisNameLocation || "middle"
      }
    ],
    series: [
      {
        name: obj.seriesBarName,
        type: "bar",
        label: {
          show: true,
          position: "outside",
        },
        data: obj.seriesBarData,
      },
      {
        name: obj.seriesLineName,
        type: "line",
        label: {
          show: true,
          position: "outside",
        },
        yAxisIndex: 1,
        data: obj.serLineData,
      },
    ],
  }
}

// 折线图
export function lineOptions(obj) {
  return {
    title: {
      text: obj.titleText,
      subtext: obj.titleSubText,
    },
    legend: {
      data: obj.legendData,
    },
    xAxis: {
      type: 'category',
      data: obj.xAxisData
    },
    yAxis: {
      type: 'value'
    },
    // series: [{
    //   data: obj.serLineData,
    //   type: 'line'
    // }]
    series: obj.series
  }
}
// 柱状图
export function barOptions(obj) {
  return {
    title: {
      text: obj.titleText,
      subtext: obj.titleSubText,
    },
    legend: {
      data: obj.legendData,
    },
    xAxis: {
      type: 'category',
      data: obj.xAxisData
    },
    yAxis: {
      type: 'value'
    },
    series: obj.series
  }
}

// 饼图
export function pieOptions(obj) {
  return {
    title: {
      text: obj.titleText,
      subtext: obj.titleSubText
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left',
    },
    series: [
      {
        name: obj.seriesPieName,
        type: 'pie',
        radius: ['30%', '50%'],
        data: obj.seriesPieData,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
}